package com.concurrency.example.immutable;

import com.google.common.collect.Maps;

import java.util.Collections;
import java.util.Map;

public class ImmutableExample2 {

    private static Map<String, String> map = Maps.newHashMap();

    static {
        map.put("name","令狐冲");
        map.put("age","33");
        map = Collections.unmodifiableMap(map); //map不允许修改
    }

    public static void main(String[] args) {
        map.put("name", "任盈盈");//不允许修改，运行时抛出异常

    }
}
